$def with (config, rtorrent)

$def selected(value, valid):
    $if value == valid:
        selected

<table id="controls">
    <tr>
        <td><input type='submit' name='start' value='' class="start"></td>
        <td><input type='submit' name='stop' value='' class="stop"></td>
        <td>
            URL:&nbsp; <input type="text" name="url" class="url"> &nbsp;or<br>
            <input type='file' name='ufile' class="file">
            
        </td>
        <td><input type='submit' name='add' value='' class="addurl"></td>
        <td><input type='submit' name='delete' value='' class="delete"></td>
        <td><a href="/list/" title="refrash"><img src="/static/images/view-refresh.png" alt="refrash"></a></td>
        <td><a href="/settings/" title="settings"><img src="/static/images/preferences-system.png" alt="settings"></a></td>
    </tr>
</table>

<div id="wraper">
<form action="/settings/" method="post">
<table id="settings">
<tr>
<td colspan="2"><h2>Main Settings</h2></td>
</tr><tr>
<td>Protocol:</td>
<td>
<select name="protocol">
<option value="scgi" $selected(config.protocol, "scgi")>scgi</option>
<option value="xmlrpc" $selected(config.protocol, "xmlrpc")>xmlrpc</option>
</select></td>
</tr><tr id="url">
<td>rTorrent URL:</td>
<td><input type="text" name="url" value="$config.url"></td>
</tr><tr id="domain">
<td>wrTorrent.py domain:</td>
<td><input type="text" name="domain" value="$config.domain"></td>
</tr><tr id="multicall">
<td>Using multicall only for hash:</td>
<td>
    <select name="multicall">
        <option $selected(config.multicall, 1) value=1>No</option>
        <option $selected(config.multicall, 0) value=0>Yes</option>
    </select>
</td>
</tr><tr>
<td colspan="3" class="description">NB! It's very slow. Use only if you have XMLRPC Fault -503.</td>
</tr><tr>
<td colspan="2"><input type="submit" value="Save"></td>
</tr></table>
</form>

<table id="settings">
<tr>
<td colspan="3"><h2>rTorrent Settings</h2></td>
</tr>
$if not rtorrent is None:
    $for c in rtorrent:
        <form action="/set_rtorrent/" method="post">
        <tr>
        <td colspan="3">
        <h3>$c settings</h3></td>
        </tr>
        $for s in rtorrent[c]:
            <tr id="$s">
            <td>$rtorrent[c][s][0]:</em></td>
            <td><input type="text" name="set_$s" value="$rtorrent[c][s][3]"></td>
            <td><em>$rtorrent[c][s][1]</td>
            </tr><tr>
            <td colspan="3" class="description">$rtorrent[c][s][2]</td></tr>
        <tr>
        <td colspan="3"><input type="submit" value="Save"></td>
        </tr>
        </form>
$else:
    <tr><td colspan="3">Not connected.</td></tr>
</table>
</div>
